package edu.udlap.spring2008.is300.finalexam.framework.mvc.model.database.filters;

import java.util.ArrayList;

/**
 *
 * @author Ruslán Ledesma Garza
 */
public abstract class ImageRecordFilterDecorator extends ImageRecordFilter
{
    protected ImageRecordFilter decoratedImageRecordFilter_;
    
    protected abstract String getSqlConstraints_();
    
    @Override
    public String getSqlConstraints()
    {
        String sqlConstraints = getSqlConstraints_();
        if(decoratedImageRecordFilter_ == null)
            return sqlConstraints;
        else
            return sqlConstraints +
                   " AND " +
                   decoratedImageRecordFilter_.getSqlConstraints();
    }

    @Override
    public ArrayList<ImageRecordFilter> getAppliedImageRecordFilters()
    {
        ArrayList<ImageRecordFilter> result;
        
        if(decoratedImageRecordFilter_ == null)
            result = new ArrayList<ImageRecordFilter>();
        else
            result = decoratedImageRecordFilter_.getAppliedImageRecordFilters();
        
        result.add(this);
        
        return result;
    }
}
